<template>
  <div class="contents">
    <PanelTitle title="信息发布" />
    <div class="mt conbon">
      <div class="infoPanel">
        <div>
          <div class="infoTitle">累计发布</div>
          <div class="infoNumss">
            <span class="infoNum">{{ statistData.totalRelNum }}</span>
            <span class="infoUnit">条</span>
          </div>
        </div>
        <div>
          <div class="infoTitle">今日发布</div>
          <div class="infoNums">
            <span class="infoNum">{{ statistData.relNum }}</span>
            <span class="infoUnit">条</span>
          </div>
          <div class="infoSub">同比 {{ statistData.relNumRatio }}%</div>
        </div>
        <div>
          <div class="infoTitle">累计阅读</div>
          <div class="infoNumss">
            <span class="infoNum">{{ statistData.totalReadNum }}</span>
            <span class="infoUnit">万次</span>
          </div>
        </div>
        <div>
          <div class="infoTitle">今日阅读</div>
          <div class="infoNums">
            <span class="infoNum">{{ statistData.readNum }}</span>
            <span class="infoUnit">次</span>
          </div>
          <div class="infoSub">同比 {{ statistData.readNumRatio }}%</div>
        </div>
      </div>
      <div>
        <table>
          <thead>
            <tr>
              <th style="width: 40%;">资讯标题</th>
              <th style="width: 20%;">资讯分类</th>
              <th style="width: 20%;">发布时间</th>
              <th style="width: 20%;">阅读次数</th>
            </tr>
          </thead>
        </table>
        <LoopScroll style="height: 18vh;">
        <table>
          <tbody>
            <tr v-for="item in articleList">
              <td style="width: 40%;">
                {{ item.title }}
              </td>
              <td style="width: 20%;">{{ item.type }}</td>
              <td style="width: 20%;">{{ item.releaseTime.split(' ')[0] }}</td>
              <td style="width: 20%;">{{ item.readNum }}次</td>
            </tr>
          </tbody>
        </table>
        </LoopScroll>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import PanelTitle from "../../component/PanelTitle.vue";
import http from "@/api/http";
import { env } from "@/utils/env";
import LoopScroll from "@/components/loopScroll.vue";

let statistData = ref({});
let articleList = ref([]);

onMounted(async () => {
  let res = await http({
    url: env.VITE_ZHER_DATA_CENTER + "/farming/article/statist",
    method: "get",
  });
  statistData.value = res.data;

  let ress = await http({
    url: env.VITE_ZHER_DATA_CENTER + "/farming/article/list",
    method: "get",
    params: { pageNum: 1, pageSize: 10 },
  });
  articleList.value = ress.data.list;
});
</script>

<style scoped lang="scss">
.contents {
  background: linear-gradient(to bottom,
      rgba(5, 79, 99),
      rgba(5, 79, 99, 0.1),
      rgba(5, 79, 99));
  border-radius: vh(8);
  border: vh(1) solid rgba(6, 112, 180, 1);

  .mt {
    margin-top: vh(-40);
  }
}

.infoPanel {
  display: flex;
  align-items: center;
  justify-content: space-around;
  align-content: center;
  flex-wrap: wrap;
  // padding: 0 vw(15) 0;
  width: 46%;

  >div {
    box-sizing: border-box;
    width: vw(130);
    height: vh(80);
    background: rgba(9, 36, 44, 0.4);
    border: vh(1) solid #43e7ff;
    padding: 0 vw(20) 0px;
    margin: vh(6) 0;
  }

  .infoTitle {
    color: #fff;
    font-size: vh(10);
    line-height: vh(30);
  }

  .infoNums {
    line-height: vh(20);
  }

  .infoNumss {
    line-height: vh(36);
  }

  .infoNum {
    color: #adffd7;
    font-size: vh(26);
    font: SourceHanSansCN-Bold;
  }

  .infoUnit {
    color: #adffd7;
    font-size: vh(16);
    font: SourceHanSansCN-Bold;
    margin-left: vw(4);
  }

  .infoSub {
    font-weight: 400;
    font-size: vh(10);
    color: #adffd7;
    line-height: vh(20);
  }
}

.conbon {
  display: flex;
  align-items: center;
}

table,
th,
td {
  border: vh(1) solid #2cd7bc;
  border-collapse: collapse;

  font-family: Source Han Sans CN;
  font-weight: 500;
  font-size: vh(10);
  text-align: center;
}

table {
  width: vw(344);
 
  margin: 0 auto;
  margin-right: vw(10);
}

th {
  color: #fff;
  background: rgba(50, 200, 167, 0.45);
  min-width: vw(60);
  line-height: vh(20);
  padding: vh(4) 0;
}

td {
  color: #2cd7bc;
  line-height: vh(14);
  padding: vh(4) 0;
}

.td-title {
  overflow: hidden;
  /* 确保超出容器的内容被裁剪 */
  white-space: nowrap;
  /* 确保文本在一行内显示 */
  text-overflow: ellipsis;
  /* 超出部分显示省略号 */
  
}
</style>